package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/3/13 10:54
 * @apiNote
 */

public class Test02864MaximumOddBinaryNumber {

    public static void main(String[] args) {
        String s = "010";
        String res = maximumOddBinaryNumber(s);
        System.out.println(res);
    }

    public static String maximumOddBinaryNumber(String s) {
        int n = s.length();
        int count = 0;
        for (char ch : s.toCharArray()) {
            if (ch == '1') {
                count++;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < count; i++) {
            sb.append('1');
        }
        int count0 = n - count;
        for (int i = 1; i <= count0; i++) {
            sb.append('0');
        }
        sb.append('1');
        return sb.toString();
    }
}
